home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / pccursor.zip / PCCURSOR.HPP < prev   
C/C++ Source or Header  |  1991-04-15  |  1KB  |  52 lines

  1. /*
  2.  
  3.     pccursor.hpp
  4.     4-15-91
  5.     Cursor shape class for IBM PC text modes.
  6.  
  7.     Copyright 1991
  8.     John W. Small
  9.     All rights reserved
  10.     Use freely but acknowledge authorship and copyright.
  11.     CIS: 73757,2233
  12.  
  13.     PSW / Power SoftWare
  14.     P.O. Box 10072
  15.     McLean, Virginia 22102 8072
  16.     USA (703) 759-3838
  17.  
  18. */
  19.  
  20. #ifndef PCCURSOR_CPP
  21. #define PCCURSOR_CPP
  22.  
  23. #include <dos.h>
  24.  
  25. #define  CursorOffMask       0x2000
  26. #define  CursorOnMask        0xDFFF
  27. #define  BlockCursorMask     0x00FF
  28. #define  DefaultColorCursor  0x0607
  29. #define  DefaultMonoCursor   0x0C0D
  30.  
  31. class CursorShape {
  32.     unsigned origshape, prevshape;
  33. protected:
  34.     unsigned  getshape() { _BH = 0x00; _AH = 0x03;
  35.         geninterrupt(0x10); return _CX; }
  36.     void putshape(unsigned shape);
  37.     unsigned defaultshape() { _AH = 0x0F;
  38.         geninterrupt(0x10); return (_AL == 7)?
  39.         DefaultMonoCursor : DefaultColorCursor; }
  40. public:
  41.     CursorShape() { origshape = prevshape = getshape(); }
  42.     void off() { putshape(getshape() | CursorOffMask); }
  43.     void on()  { putshape(getshape() & CursorOnMask); }
  44.     void block() { putshape(defaultshape() & BlockCursorMask); }
  45.     void normal()  { putshape(defaultshape()); }
  46.     void save()    { prevshape = getshape(); }
  47.     void restore() { putshape(prevshape); }
  48.     ~CursorShape() { putshape(origshape); }
  49. };
  50.  
  51. #endif
  52.